package com.itheima.controller;

import com.itheima.common.entity.Result;
import com.itheima.service.StatisticService;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
import java.util.Map;

@RestController
@RequestMapping("/report")
public class StatisticController {

    @Autowired
    private StatisticService statisticService;


    //获取会员数量统计数据
    @GetMapping("/getMemberReport")
    public Result getMemberReport() {
        Map<String, Object> memberCount = statisticService.getMemberReport();
        return new Result(true, "获取会员统计数据成功", memberCount);
    }


    //获取预约套餐占比统计数据
    @GetMapping("/getSetmealReport")
    public Result getSetmealReport() {
        Map<String, Object> setmealCount = statisticService.getSetmealReport();
        return new Result(true, "获取套餐统计数据成功", setmealCount);
    }

    //获取运营统计数据
    @GetMapping("/getBusinessReportData")
    public Result getBusinessReportData() {
        Map<String, Object> businessReportData = statisticService.getBusinessReportData();
        return new Result(true, "获取运营统计数据成功", businessReportData);
    }

    //导出运营数据到Excel并提供客户端下载
    @GetMapping("/exportBusinessReport")
    public void exportBusinessReport(HttpServletResponse response) throws IOException {
        statisticService.exportBusinessReport(response);
    }

}
